package problem137;

//137.只出现过一次的数字2
//https://leetcode.cn/problems/single-number-ii/

class Solution {
    public int singleNumber(int[] nums) {
        int ret = 0;
        for(int i = 0; i<32; i++) {
            int sum = 0;
            for(int x : nums) {
                sum += ((x >> i) & 1);
            }
            sum %= 3;
            ret |= (sum << i);
        }
        return ret;
    }
}